package me.huanmeng.heater.signalling.extra.data.event;

import lombok.Data;
import lombok.EqualsAndHashCode;
import me.huanmeng.heater.Heater;
import me.huanmeng.heater.object.UserInfo;
import me.huanmeng.heater.signalling.ChannelType;
import me.huanmeng.heater.signalling.extra.SignallingExtraData;

/**
 * 2021/9/28<br>
 * Heater<br>
 *
 * @author huanmeng_qwq
 */
@EqualsAndHashCode(callSuper = true)
@Data
public class UserUpdate extends SignallingExtraData<String> {
    protected UserUpdateBody body;

    @Override
    public ChannelType getChannelType() {
        return ChannelType.PERSON;
    }

    @Override
    public void execute() {
        final UserInfo user = Heater.getUserInfo(body.user_id);
        user.setUsername(body.username);
        user.setAvatar(body.avatar);
    }

    @Data
    public static class UserUpdateBody {
        protected String user_id;
        protected String username;
        protected String avatar;
    }
}
